import { defHttp } from '@/utils/http/axios';
import { PageRouterModel, RouterPageArgs } from '@/api/system/model/gatewayModel';

const basePath = '/system/gateway/router';
const buildUrl = (url: string) => basePath + url;

enum Api {
  PageRouter = '/pageQuery',
  AddOrUpdate = '/addOrUpdate',
  DeleteRouterById = '/deleteById',
  ConfigDeleteById = '/config/deleteById',
  RefreshSign = '/refreshSign',
  RefreshAll = '/refreshAll',
  GatewayRouterDel = '/delete',
}

export const pageList = (params: RouterPageArgs) =>
  defHttp.post<PageRouterModel>({
    url: buildUrl(Api.PageRouter),
    params: { page: params.page, pageSize: params.pageSize, t: params },
  });

export const addOrUpdate = (params: any) =>
  defHttp.post({ url: buildUrl(Api.AddOrUpdate), params });

export const deleteRouterById = (id: string) =>
  defHttp.get({ url: buildUrl(Api.DeleteRouterById) + '/' + id });

export const configDeleteById = (id: string) =>
  defHttp.get({ url: buildUrl(Api.ConfigDeleteById) + '/' + id });

export const gatewayRouterDel = (id: string) =>
  defHttp.get({ url: Api.GatewayRouterDel + '/' + id });

export const refreshSignGateway = (data: any) =>
  defHttp.post({
    url: Api.RefreshSign,
    data,
  });

export const refreshAllGateway = () => defHttp.get({ url: Api.RefreshAll });
